$(document).ready(function() {	
	$( 'textarea#pcontent' ).ckeditor();
	$("#frmEdit").validate({
		errorClass		: 'error',
		errorElement	: 'span',
		onfocusout		: false,
		onkeyup			: false,
		ignore			: "input[type='text']:hidden",
		rules: {			
			pname: {
				required			: true,
				minlength			: VL_NAME_MINLENGTH
			},
			pimage: {				
				validateImgFormat		: true,
				validateImgSize			: true
			},
			pcontent: {
				requiredContent		: true,
				minlengthContent	: true
			}
		},
		messages: {	
			pname: {
				required			: name_required,
				minlength			: name_minlength
			},
			pimage: {				
				validateImgFormat		: image_format,
				validateImgSize			: image_size
			},
			pcontent: {
				requiredContent		: content_required,
				minlengthContent	: content_minlength
			}
		},
		errorPlacement: function(label, element) {			
			var id = element.attr('id');	
			if (id == 'pcontent')	{
				label.insertAfter($('#cke_pcontent'));
			}else {
				label.insertAfter($('#' + id));			
			}
		}/*,
		submitHandler: function(form) {				
			form.submit();
		}*/
	});	
	$.validator.addMethod('validateImgFormat', function() {
		var strLinkImage = $('#pimage').val();
		if(strLinkImage == '') {
			return true;
		}
		return validateImage(strLinkImage);
	});
	$.validator.addMethod('validateImgSize', function() {
		var strLinkImage = $('#pimage').val();
		if(strLinkImage == '') {
			return true;
		}
		return validateImgSize('pimage');
	});	
	$.validator.addMethod('requiredContent',function(){
		var strContent	= stripTags($('#pcontent').val(), 1);	
		if(strContent == '')
			return false;		
		return true;												 
	});
	$.validator.addMethod('minlengthContent',function(){
		var strContent	= stripTags($('#pcontent').val(), 1);	
		if(strContent != '' && strContent.length < VL_CONTENT_MINLENGTH)
			return false;		
		return true;												 
	});
});